package com.wlc.collection;


import java.util.LinkedList;
import java.util.Stack;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description 栈
 * @date 2021-07-11 20:13
 */
public class MyStackDemo extends Stack {

    LinkedList<Hero> heros = new LinkedList<Hero>();


    public void push(Hero h) {
        heros.addLast(h);
    }


    public Hero pull() {
        return heros.removeLast();
    }


    @Override
    public Hero peek() {
        return heros.peek();
    }

    public static void main(String[] args) {

        MyStackDemo heroStack = new MyStackDemo();
        for (int i = 0; i < 5; i++) {
            Hero h = new Hero("hero name " + i, 20);
            System.out.println("压入 hero:" + h);
            heroStack.push(h);
        }
        for (int i = 0; i < 5; i++) {
            Hero h = heroStack.pull();
            System.out.println("弹出 hero" + h);
        }
    }

}